package com.weme.chamet.ui


import com.osom.proto.message.NetworkOuterClass
import com.weme.common.base.BaseViewModel
import com.weme.common.manager.SocketManager
import com.weme.common.network.NetWorkUrl
import dev.kratos.api.cms_server.v1.CallConfigRequest
import dev.kratos.api.cms_server.v1.KeyValueConfigRequest
import dev.kratos.api.user_server.v1.CheckLoginRequest

class SplashViewMode : BaseViewModel() {

    fun getSevriceInfo() {

        try {
            sendCmsNetworkRequest(KeyValueConfigRequest.newBuilder().build().toByteArray(), NetWorkUrl.KeyValueConfig)
            sendCmsNetworkRequest(CallConfigRequest.newBuilder().setAppId(APPID).build().toByteArray(), NetWorkUrl.CallConfig)

        } catch (e: Exception) { //log.error(e)
        }


    }

    fun userLoginApi(req: NetworkOuterClass.LoginRequest) {

        try {
            SocketManager.send(req, NetworkOuterClass.NetworkCommand.CMD_GATEWAY_LOGIN_REQUEST.number, 0)
        } catch (e: Exception) { //log.error(e)
        }
    }


    fun checkLoginApi(req: CheckLoginRequest) {

        try {
            sendNetworkRequest(req.toByteArray(), NetWorkUrl.CheckLogin)
        } catch (e: Exception) { //log.error(e)
        }
    }
}